﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Kotonoha.Server.Objects.Model;
using Microsoft.Windows.Controls;

namespace Kotonoha.Server.UI.Model {
    /// <summary>
    /// Interaction logic for WordForm.xaml
    /// </summary>
    public partial class WordForm : Window {
        public WordForm() {
            InitializeComponent();
        }

        private void CancelBtn_Click(object sender, RoutedEventArgs e) {
            DialogResult = false;
            this.Close();
        }

        private void OkBtn_Click(object sender, RoutedEventArgs e) {
            DialogResult = true;
            this.Close();
        }
        
        private void DataGrid_CellEditEnding(object sender, Microsoft.Windows.Controls.DataGridCellEditEndingEventArgs e) {
            TextBox box = (TextBox) e.EditingElement;
            Word w = (Word) this.DataContext;
            w.Translations[e.Row.AlternationIndex] = box.Text;
            DataContext = w;
            TranslationGrid.DataContext = w;
            
        }
    }
}
